<?php 
namespace app\admin\controller;
use think\Db;
class AdminLog extends Base{
	public function index(){
		$page = $this->request->param('page/d',1);
		$limit = $this->request->param('limit/d',20);
		$where=NULL;
		$totalCount = Db::table('admin_log')
				->alias('al')
				->field("al.id,al.title,al.ip,al.create_time,a.username")
				->where($where)
				->join(['administrator'=>'a'],'al.admin_id = a.id')
				->count();
		$list = Db::table('admin_log')
				->alias('al')
				->field("al.id,al.title,al.ip,al.create_time,a.username")
				->where($where)
				->join(['administrator'=>'a'],'al.admin_id = a.id')
				->page($page,$limit)
				->order('id','DESC')
				->select();
		foreach ($list as $key => $value) {
			$list[$key]['create_time_str'] = date("Y-m-d H:i:s",$value['create_time']);
		}
		$data['code'] = 0;
		$data['data'] = $list;
		$data['count'] = $totalCount;
		$data['msg'] = '请求成功';

		if( $this->request->isAjax() ){
			return $data;
		}else{
			return $this->fetch();
		}
	}

}